﻿using Estsh.Core.Model.Extend.IFModels;
using Estsh.Core.Model.Extend.Models;
using Estsh.Core.Model.Result;
using Estsh.Core.Models;
using Estsh.Core.Quartz.BaseService;
using Estsh.Core.Util;
using Estsh.Core.Wms.IRepositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Estsh.Core.Wms.Jobs
{
    /// <summary>
    /// 物流公司信息
    /// </summary>
    public class WMSLogisticsInfoJob : IJobService
    {
        private readonly IInterfaceMasterRepository repository;


        public WMSLogisticsInfoJob(IInterfaceMasterRepository _repository)
        {
            this.repository = _repository;

        }
        public string ExecuteService(string parameter)
        {
            try
            {
                List<WmsLogistics> logisticsinfos = repository.GetLogisticsInfo();
                if (logisticsinfos.Count <= 0)
                {
                    return "没有待处理的物流公司信息！";
                }

                bool result = repository.InsertLogisticsInfo(logisticsinfos);
                if (result == true)
                {
                    return "物流公司信息数据同步成功！";
                }
                else
                {
                    return "物流公司信息数据同步失败！";
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("物流公司信息接口错误！" + ex);
                return "物流公司信息接口错误！" + ex.Message;
            }
        }
    }
}
